// See "source_line_resolver_base.h" and
// "breakpad/source_line_resolver_interface.h" for more reference.
//

#ifndef LONGKEY_BREAKPAD_PROCESSOR_FAST_SOURCE_LINE_RESOLVER_H_
#define LONGKEY_BREAKPAD_PROCESSOR_FAST_SOURCE_LINE_RESOLVER_H_

#include <map>
#include <string>
#include "source_line_resolver_base.h"

namespace longkey_breakpad
{
	using std::map;

	class FastSourceLineResolver : public SourceLineResolverBase
	{
	public:
		FastSourceLineResolver();
		virtual ~FastSourceLineResolver() {}

		using SourceLineResolverBase::FillSourceLineInfo;
		using SourceLineResolverBase::FindCFIFrameInfo;
		using SourceLineResolverBase::FindWindowsFrameInfo;
		using SourceLineResolverBase::HasModule;
		using SourceLineResolverBase::LoadModule;
		using SourceLineResolverBase::LoadModuleUsingMapBuffer;
		using SourceLineResolverBase::LoadModuleUsingMemoryBuffer;
		using SourceLineResolverBase::UnloadModule;

	private:
		// Friend declarations.
		friend class ModuleComparer;
		friend class ModuleSerializer;
		friend class FastModuleFactory;

		// Nested types that will derive from corresponding nested types defined in
		// SourceLineResolverBase.
		struct Line;
		struct Function;
		struct PublicSymbol;
		class Module;

		// Deserialize raw memory data to construct a WindowsFrameInfo object.
		static WindowsFrameInfo CopyWFI(const char *raw_memory);

		// FastSourceLineResolver requires the memory buffer stays alive during the
		// lifetime of a corresponding module, therefore it needs to redefine this
		// virtual method.
		virtual bool ShouldDeleteMemoryBufferAfterLoadModule();

		// Disallow unwanted copy ctor and assignment operator
		FastSourceLineResolver(const FastSourceLineResolver&);
		void operator=(const FastSourceLineResolver&);
	};
}

#endif	// LONGKEY_BREAKPAD_PROCESSOR_FAST_SOURCE_LINE_RESOLVER_H_